<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/10
 * Time: 10:32
 */

namespace app\common\model;
use app\common\CompanyModel;
use app\common\AdminroleModel;
use think\Model;
//平台管理员表
class LoginModel extends Model
{
    protected $table = 'xt_admin';

    // 登录
    public static function login_in($username, $password)
    {
        // 查询用户信息
        $ret_master_find = LoginModel::field("*")
            ->where('username', '=', $username)
            ->find();
        if (!$ret_master_find) {
            return retInfo('', 201, '账号不存在');
        }
        else if ($ret_master_find['password'] !== md5(md5($password))) {
            return retInfo('', 203, '密码错误');
        }
        $master = $ret_master_find->toArray();
        unset($master['password']);
        session('platform', $master);
        return retInfo('', 200, '成功');
    }
    //退出
    public static function login_out() {
        session('platform', null);
        return true;
    }
}